//
//  KLStayTableViewCell.m
//  KunLun
//
//  Created by Mac on 2017/11/27.
//  Copyright © 2017年 stoneobs@icloud.com. All rights reserved.
//

#import "KLStayTableViewCell.h"

@interface KLStayTableViewCell()
@property(nonatomic, strong) UIImageView                     *iconImageView;
@property(nonatomic, strong) STLabel                            *titleLable;
@property(nonatomic, strong) STLabel                            *addLable;//评分和位置
@property(nonatomic, strong) STLabel                            *moneyLbale;//id
@property(nonatomic, strong) STLabel                            *destanceLbale;//距离
@property(nonatomic, strong) STLabel                            *numLbale;//剩余多少放
@end
@implementation KLStayTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self ==[super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self configSubView];
    }
    return self;
}
+ (CGFloat)cellHeight{
    return 110;
}
#pragma mark --subView
- (void)configSubView{
    
    self.backgroundColor = [UIColor whiteColor];
    
    self.iconImageView = [[UIImageView alloc] initWithFrame:CGRectMake(15, 5, 100, 100)];
    self.iconImageView.image = [UIImage imageNamed:@"09"];
    [self addSubview:self.iconImageView];
    
    self.titleLable = [[STLabel alloc] initWithFrame:CGRectMake(self.iconImageView.right + 10, self.iconImageView.top + 5, UIScreenWidth - self.iconImageView.right - 20, 20)
                                                text:@"北京红烧饭大酒店"
                                           textColor:KL_firstTextColor
                                                font:15
                                         isSizetoFit:NO
                                       textAlignment:NSTextAlignmentLeft];
    [self addSubview:self.titleLable];
    
    self.addLable = [[STLabel alloc] initWithFrame:CGRectMake(self.iconImageView.right + 10, self.titleLable.bottom +3, UIScreenWidth - self.iconImageView.right - 20, 45)
                                               text:@"4.5分   北京市汉鼎去双清路22号"
                                          textColor:KL_secendTextColor
                                               font:14
                                        isSizetoFit:NO
                                      textAlignment:NSTextAlignmentLeft];
    [self addSubview:self.addLable];
    
    self.moneyLbale = [[STLabel alloc] initWithFrame:CGRectMake(self.iconImageView.right + 10, self.addLable.bottom + 3, 250, 20)
                                              text:@"$455"
                                         textColor:KL_redColor
                                              font:14
                                       isSizetoFit:NO
                                     textAlignment:NSTextAlignmentLeft];
    [self addSubview:self.moneyLbale];
    
    
    self.destanceLbale = [[STLabel alloc] initWithFrame:CGRectMake(self.iconImageView.right + 10, self.addLable.bottom + 3, 120, 20)
                                                   text:@"距离:12km"
                                           textColor:KL_secendTextColor
                                                font:14
                                         isSizetoFit:NO
                                       textAlignment:NSTextAlignmentRight];
    self.destanceLbale.right = UIScreenWidth - 10;
  //  [self addSubview:self.destanceLbale];
    
    self.numLbale = [[STLabel alloc] initWithFrame:CGRectMake(self.iconImageView.right + 10, self.moneyLbale.bottom + 10, UIScreenWidth - self.iconImageView.right - 20, 20)
                                              text:@"剩余20件房"
                                         textColor:KL_secendTextColor
                                              font:14
                                       isSizetoFit:NO
                                     textAlignment:NSTextAlignmentRight];
   // [self addSubview:self.numLbale];
}
- (void)setGoodModel:(KLGoodModel *)goodModel{
    _goodModel = goodModel;
    
    self.titleLable.text = goodModel.goods_name;
    self.addLable.text = goodModel.abstract;
    
    self.moneyLbale.text = [NSString stringWithFormat:@"￥%@",goodModel.price];
    if (goodModel.discount_price.length) {
        self.moneyLbale.text = [NSString stringWithFormat:@"￥%@  原价:￥%@",goodModel.discount_price,goodModel.price];
        NSString * originPrice = [NSString stringWithFormat:@"原价:%@",goodModel.price];
        NSDictionary *attribtDic = @{NSStrikethroughStyleAttributeName: [NSNumber numberWithInteger:NSUnderlineStyleSingle],NSForegroundColorAttributeName:KL_secendTextColor};
        self.moneyLbale.attributedText = [self.moneyLbale.text st_convertAttributeStringWithKeyWord:originPrice attributes:attribtDic];
    }
    self.numLbale.text =  @"剩余20件房";
    
    [self.iconImageView sd_setImageWithURL:[NSURL URLWithString:goodModel.exhibition_map]];
    
    
}
@end
